//author:jxx
//此处是对表单的方法，组件，权限操作按钮等进行任意扩展(方法扩展可参照SellOrder.js)
let extension = {
  components: {//动态扩充组件或组件路径
    //表单header、content、footer对应位置扩充的组件
    gridHeader: '',//{ template: "<div>扩展组xx件</div>" },
    gridBody: '',
    gridFooter: '',
    //弹出框(修改、编辑、查看)header、content、footer对应位置扩充的组件
    modelHeader: '',
    modelBody: '',
    modelFooter: ''
  },
  buttons: { view: [], box: [], detail: [] },//扩展的按钮
  methods: {//事件扩展
    getFormOption (field) {
      let option;
      this.editFormOptions.forEach(x => {
        x.forEach(item => {
          if (item.field == field) {
            option = item;
          }
        })
      })
      return option;
    },
    onInit () {
      let sharing_rules = this.getFormOption('sharing_rules');
      let money = this.getFormOption('money');
      let proportion = this.getFormOption('proportion');
      sharing_rules.onChange = (v) => {
        money.hidden = true
        proportion.hidden = true
        money.required = false
        proportion.required = false
        if (v == 0) {
          money.hidden = false
          this.editFormFields.proportion = 0
        } else {
          proportion.hidden = false
          this.editFormFields.money = 0
        }
      }
    },
    rowClick ({ row, column, event }) {
      //查询界面table点击行选中当前行
      this.$refs.table.$refs.table.toggleRowSelection(row);
      return true;
    },
    modelOpenAfter (row) {
      let money = this.getFormOption('money');
      let proportion = this.getFormOption('proportion');
      let goodName = this.getFormOption('goodName');
      let goodCode = this.getFormOption('goodCode');
      money.hidden = true
      proportion.hidden = true
      if (this.currentAction == "Add") {
        goodName.disabled = false
        goodCode.disabled = false
        goodName.required = true
        goodCode.required = true
      } else {
        goodName.disabled = true
        goodCode.disabled = true
        goodName.required = false
        goodCode.required = false
        if (row.sharing_rules == 0) {
          money.hidden = false
        } else {
          proportion.hidden = false
        }
      }
    },
  }
};
export default extension;
